<?php


namespace app\api\model;

use app\api\controller\Code;
use think\Db;
use think\Model;

/**
 * 游戏信息
 * Class GameModel
 * @package app\api\model
 *
 */
class GameModel extends Model
{

    /**
     * 设置表名
     * @var string
     */
    protected $table = 'te_game';

    /**
     *
     * 游戏列表
     */
    public static function gameList(){

        $where = ['status'=>1,'is_deleted'=>0];
        $field = 'id,name,hot_value';
        return self::where($where)
            ->where(['pid'=>0])
            ->field($field)
            ->order('id asc')
            ->select()->each(function ($item)use ($where,$field){

                $item['child'] = self::where($where)
                    ->where(['pid'=>$item['id']])
                    ->field($field)
                    ->order('id asc')
                    ->select();
            });
    }



}